package org.mspring.platform.web.render;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.http.HttpServletResponse;

/**
 *
 * @author Gao Youbo
 * @since 2013-2-6
 */
public class ScriptRender extends AbstractResponseRender {

    private String script;

    public String getScript() {
        return script;
    }

    public void setScript(String script) {
        this.script = script;
    }

    public ScriptRender() {

    }

    public ScriptRender(String script) {
        super();
        this.script = script;
    }

    @Override
    public void render(HttpServletResponse response) {
        try {
            response.setContentType("text/javascript");
            response.setCharacterEncoding("UTF-8");
            try (PrintWriter writer = response.getWriter()) {
                writer.write(this.script);
            }
        } catch (IOException e) {
        }
    }

}
